<?php

class Order extends CI_Controller {
	
	function Order() {
		parent::__construct();
		$this->load->model('be/order_model', 'model');
	}
	
	function index() {
		$this->list_all();
	}
	
	function list_all() {
		$orders =  $this->model->get();
		$data['orders'] = $orders;
		$data['page_title'] = 'Danh sách hóa đơn';
		$data['main_content'] = 'be/orders/list';
		$this->load->view('be/includes/template', $data);
	}
	
	function detail($id) {
		$order = $this->model->get($id);
		$data['title'] = $order->title;
		$data['content'] = $order->content;
		$data['card_id'] = $order->card_id;
		$data['create_on'] = $order->create_on;
		$data['pay_type'] = $order->pay_type;
		$data['trans_type'] = $order->trans_type;
		$data['destination'] = $order->destination;
		$data['note'] = $order->note;
		$data['quantity'] = $order->quantity;
		$data['status'] = $order->status;
		$data['customer_id'] = $order->customer_id;
		$data['visitor_id'] = $order->visitor_id;
		
		$data['page_title'] = 'Danh sách hóa đơn';
		$data['main_content'] = 'be/orders/detail';
		$this->load->view('be/includes/template', $data);
	}
	
	function delete() {
		$ids = $this->input->post('selected');
		foreach ($ids as $id){
			$this->model->delete($id);
		}
		redirect(site_url('order'));
	}
} 